The technology described herein relates to data processing systems, and in particular to methods and apparatus for converting between different number representations in data processing systems.
Data processing systems, such as graphics processing systems, typically handle numbers using various different representations.
One common way in which a number can be represented in data processing systems is using the floating point representation, e.g. in accordance with the IEEE 754 Standard. The floating point representation of a number will typically include a sign, an exponent and a mantissa, and will have a certain precision such as 16-bit, 32-bit or 64-bit precision.
Another common way in which a number can be represented in data processing systems is using the unsigned normalized integer, or “unorm”, representation, e.g. as defined in DirectX. In this case, a number between 0 and 1 is represented using an integer between 0 and (2b−1), where b is the number of bits, i.e. the precision, of the unorm representation. In other words, numbers in the range 0 to 1 are linearly mapped to integers in the range 0 to (2b−1), e.g. using rounding to the nearest integer.
In data processing systems, such as graphics processing systems, it is often necessary to convert between the various different number representations that are supported and used, and in particular to convert between the floating point representation of a number and the unorm representation of the number. This can arise, for example, in graphics processing systems where depth (“Z”) values, colour values, etc., used in graphics processing operations can often be represented using both the floating point representation and the unorm representation.
When using rounding to the nearest integer, the value of a b-bit unorm representation U of a number x is given by the equation:U=floor(x×(2b−1)+0.5),  (1)where the unorm representation U is clamped according to:                U=2b−1 for x≥1.0, and        U=0 for x≤0,i.e. the unorm representation U is set to its maximum for numbers greater than or equal to one, and is set to its minimum for numbers less than or equal to zero.        
One way in which this conversion can be achieved in hardware utilizes the fact that equation (1) can be rewritten as:U=floor(x×2b−x+0.5),and can therefore be translated into hardware as a shift operation, a subtraction operation, an addition operation, and then a truncation (floor) operation.
However, this combination of operations is relatively expensive in hardware, e.g. in terms of the required on-chip area and/or the amount of processing required, and therefore the power consumption.
The Applicants therefore believe that there remains scope for improved techniques for converting between the floating point representation of a number and the unorm representation of the number in data processing systems.
Like reference numerals are used for like components throughout the drawings, where appropriate.